package com.example.demo.servers.impl;

import com.example.demo.mapper.UserMappper;
import com.example.demo.pojo.User;
import com.example.demo.servers.Userserver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Userserverimpl implements Userserver {
    @Autowired
    private UserMappper usermappper;

    @Override
    public List<User> selectall() {
        List<User> users = usermappper.selectList(null);
        return users;
    }

    @Override
    public void adduser(User user) {
        usermappper.insert(user);
    }

    @Override
    public void update(User user) {
        usermappper.updateById(user);
    }

    @Override
    public void delectbyid(Integer id) {
        usermappper.deleteById(id);
    }

    @Override
    public User selectbyid(Integer id) {
        usermappper.selectById(id);
        return usermappper.selectById(id);
    }
}
